package com.sunway.logger.restapi;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

import org.elasticsearch.action.index.IndexResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.sunway.logger.service.IndexService;

@RestController
@RequestMapping("/save")
public class IndexController {

    @Autowired
    private IndexService indexService;

    @RequestMapping(method = POST)
    public @ResponseBody IndexResponse put(@RequestBody Log log) throws Exception {
    	return indexService.save(log);
    }
    
    @RequestMapping(method = GET)
    public @ResponseBody Log get( ) throws Exception {
    	return   new Log("estandard" , "Debug", "Hello, This is a example!");
    }

}
